import { nilV } from "utils";
class AppNotification {
    handleArr: ((...args: any) => void)[];
    constructor() {
        this.handleArr = [];
    }
    // 注册
    register(handle: (...args: any) => void) {
        this.handleArr.push(handle);
    }
    // 移除
    remove(handle?: (...args: any) => void) {
        if (nilV(handle)) {
            // 移除全部
            this.handleArr = [];
            return;
        }
        let matchIndex = this.handleArr.findIndex((e) => e === handle);
        if (matchIndex >= 0) {
            this.handleArr.splice(matchIndex, 1);
        }
    }
    // 执行
    emits(...args: any) {
        this.handleArr.forEach((e) => {
            e(...args);
        });
    }
}
export { AppNotification };
